/*
 * {comment of class}
 *
 * @author (C) <a href="http://www.carfield.com.hk">Carfield Yim </a>, 2004
 */
package hk.com.carfield.util;

import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

public class LangUtil {

	public static void exitForOOME(Throwable e) {
		// Try to exit for OOME
		do {
			if (e.getClass().equals(OutOfMemoryError.class)) {
				System.exit(1);
			}
			e = e.getCause();
		} while (e != null);
	}

	public static void incrementMap(final Map<String, AtomicInteger> map,
			final String key) {
		final AtomicInteger i = map.get(key);
		if (i == null) {
			map.put(key, new AtomicInteger(1));
		} else {
			i.incrementAndGet();
		}
	}

}
